# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=8

DESCRIPTION="Inno Setup is a free installer for Windows programs"
HOMEPAGE="https://jrsoftware.org/isinfo.php"
SRC_URI="https://files.jrsoftware.org/is/6/${P}.exe"
LICENSE="unknown"
SLOT="0"
KEYWORDS="-* amd64 x86"
IUSE=""
RESTRICT="mirror"

DEPEND=""
RDEPEND="virtual/wine[abi_x86_32]"
BDEPEND="app-arch/innoextract"

S=${WORKDIR}

src_unpack() {
        innoextract -e -s -m "${DISTDIR}/${P}.exe" || die
}

src_prepare() {
	eapply_user

	# Prepare the wrapper script
	sed -e "s/^OPTDIR=.*$/OPTDIR=\/opt\/${PN}/g" \
	    -e "s/^DATADIR=.*$/DATADIR=~\/.cache\/${PN}/g" "${FILESDIR}/iscc" > "${WORKDIR}/iscc"
}

src_install() {
	local dir=/opt/${PN}

	dobin iscc

	insinto "${dir}"
	cd app
	doins -r *
}
